<ot-view>
    <div class="row">
        <div class="col-md-12 ot-view-title">
            <ot-entity-image entity="validationStamp">
                {{validationStamp.name}}
            </ot-entity-image>
            <ot-entity-embedded-decorations decorations="validationStamp.decorations"></ot-entity-embedded-decorations>
            <div ng-show="validationStamp.description" class="ot-description">
                {{validationStamp.description}}
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-8">

            <div ng-if="validationStamp.dataType">
                <ot-section-title>Data type</ot-section-title>
                <p>
                    {{validationStamp.dataType.descriptor.displayName}}
                    <ot-validation-data-type-config value="validationStamp.dataType"></ot-validation-data-type-config>
                </p>
            </div>

            <ot-section-title>History</ot-section-title>
            <div class="alert alert-warning" ng-show="validationStamp.validationRunsPaginated.pageInfo.totalSize == 0">
                No validation run has been done yet.
            </div>
            <table class="table table-condensed table-hover" ng-show="validationStamp.validationRunsPaginated.pageInfo.totalSize != 0">
                <thead>
                <tr>
                    <th>Build</th>
                    <th>Run</th>
                    <th>Last status</th>
                    <th>Data</th>
                    <th>Description</th>
                    <th>Creation</th>
                    <th>Source</th>
                    <th>Trigger</th>
                    <th>Run time</th>
                </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="validationRun in validationStamp.validationRunsPaginated.pageItems">
                        <td>
                            <a href="#/build/{{validationRun.build.id}}">
                                {{validationRun.build.name}}
                            </a>
                        </td>
                        <td>
                            <a href="#/validationRun/{{validationRun.id}}">
                                #{{validationRun.runOrder}}
                            </a>
                        </td>
                        <td>
                            <a href="#/validationRun/{{validationRun.id}}">
                                <ot-validation-run-status status="validationRun.validationRunStatuses[0]"></ot-validation-run-status>
                            </a>
                        </td>
                        <td>
                            <span ng-if="validationRun.data">
                                <ot-validation-run-data value="validationRun.data"></ot-validation-run-data>
                            </span>
                        </td>
                        <td ng-bind-html="validationRun.validationRunStatuses[0].annotatedDescription">
                        </td>
                        <td>
                            <ot-signature value="{time: validationRun.creation.time, user: {name: validationRun.creation.user}}" user="true" time="true"></ot-signature>
                        </td>
                        <td>
                           <span ng-if="validationRun.runInfo.sourceType && validationRun.runInfo.sourceUri">
                               <a href="{{validationRun.runInfo.sourceUri}}">{{validationRun.runInfo.sourceType}}</a>
                           </span>
                        </td>
                        <td>
                           <span ng-if="validationRun.runInfo.triggerType && validationRun.runInfo.triggerData">
                               {{validationRun.runInfo.triggerType}}
                               ->
                               {{validationRun.runInfo.triggerData}}
                           </span>
                        </td>
                        <td>
                            <span ng-if="validationRun.runInfo.runTime">
                                <ot-duration duration="validationRun.runInfo.runTime"></ot-duration>
                            </span>
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="4" align="left">
                        <button class="btn btn-link" ng-show="validationStamp.validationRunsPaginated.pageInfo.previousPage" ng-click="switchPage(validationStamp.validationRunsPaginated.pageInfo.previousPage)">
                            <span class="fa fa-step-backward"></span>
                            Newer ones
                        </button>
                    </td>
                    <td colspan="4" align="right">
                        <button class="btn btn-link" ng-show="validationStamp.validationRunsPaginated.pageInfo.nextPage" ng-click="switchPage(validationStamp.validationRunsPaginated.pageInfo.nextPage)">
                            <span class="fa fa-step-forward"></span>
                            Older ones
                        </button>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
        <div class="col-md-3">
            <ot-section-title>Properties</ot-section-title>
            <div class="row">
                <div class="col-md-12">
                    <ot-entity-properties entity="{_properties: validationStamp.links._properties}"></ot-entity-properties>
                </div>
            </div>
        </div>
    </div>
    <ot-entity-events entity="{_events: validationStamp.links._events}"></ot-entity-events>
</ot-view>